<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- This file documents the use of the GNU compilers.

Copyright © 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<title>Environment Variables (Using the GNU Compiler Collection (GCC))</title>

<meta name="description" content="Environment Variables (Using the GNU Compiler Collection (GCC))">
<meta name="keywords" content="Environment Variables (Using the GNU Compiler Collection (GCC))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Indices.html" rel="index" title="Indices">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Invoking-GCC.html" rel="up" title="Invoking GCC">
<link href="Precompiled-Headers.html" rel="next" title="Precompiled Headers">
<link href="Spec-Files.html" rel="prev" title="Spec Files">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
kbd.key {font-style: normal}
span:hover a.copiable-link {visibility: visible}
-->
</style>


</head>

<body lang="en_US">
<div class="section-level-extent" id="Environment-Variables">
<div class="nav-panel">
<p>
Next: <a href="Precompiled-Headers.html" accesskey="n" rel="next">Using Precompiled Headers</a>, Previous: <a href="Spec-Files.html" accesskey="p" rel="prev">Specifying Subprocesses and the Switches to Pass to Them</a>, Up: <a href="Invoking-GCC.html" accesskey="u" rel="up">GCC Command Options</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indices.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h3 class="section" id="Environment-Variables-Affecting-GCC"><span>3.21 Environment Variables Affecting GCC<a class="copiable-link" href="#Environment-Variables-Affecting-GCC"> &para;</a></span></h3>
<a class="index-entry-id" id="index-environment-variables"></a>

<p>This section describes several environment variables that affect how GCC
operates.  Some of them work by specifying directories or prefixes to use
when searching for various kinds of files.  Some are used to specify other
aspects of the compilation environment.
</p>
<p>Note that you can also specify places to search using options such as
<samp class="option">-B</samp>, <samp class="option">-I</samp> and <samp class="option">-L</samp> (see <a class="pxref" href="Directory-Options.html">Options for Directory Search</a>).  These
take precedence over places specified using environment variables, which
in turn take precedence over those specified by the configuration of GCC.
See <a data-manual="gccint" href="https://gcc.gnu.org/onlinedocs/gccint/Driver.html#Driver">Controlling the Compilation Driver <samp class="file">gcc</samp></a> in <cite class="cite">GNU Compiler Collection (GCC) Internals</cite>.
</p>
<dl class="table">
<dt><a class="index-entry-id" id="index-LC_005fCTYPE"></a>
<a class="index-entry-id" id="index-LC_005fMESSAGES"></a>
<a class="index-entry-id" id="index-LC_005fALL"></a>
<a class="index-entry-id" id="index-locale"></a>
<a id="index-LANG"></a><span><code class="env">LANG</code><a class="copiable-link" href="#index-LANG"> &para;</a></span></dt>
<dt><code class="env">LC_CTYPE</code></dt>
<dt><code class="env">LC_MESSAGES</code></dt>
<dt><code class="env">LC_ALL</code></dt>
<dd><p>These environment variables control the way that GCC uses
localization information which allows GCC to work with different
national conventions.  GCC inspects the locale categories
<code class="env">LC_CTYPE</code> and <code class="env">LC_MESSAGES</code> if it has been configured to do
so.  These locale categories can be set to any value supported by your
installation.  A typical value is &lsquo;<samp class="samp">en_GB.UTF-8</samp>&rsquo; for English in the United
Kingdom encoded in UTF-8.
</p>
<p>The <code class="env">LC_CTYPE</code> environment variable specifies character
classification.  GCC uses it to determine the character boundaries in
a string; this is needed for some multibyte encodings that contain quote
and escape characters that are otherwise interpreted as a string
end or escape.
</p>
<p>The <code class="env">LC_MESSAGES</code> environment variable specifies the language to
use in diagnostic messages.
</p>
<p>If the <code class="env">LC_ALL</code> environment variable is set, it overrides the value
of <code class="env">LC_CTYPE</code> and <code class="env">LC_MESSAGES</code>; otherwise, <code class="env">LC_CTYPE</code>
and <code class="env">LC_MESSAGES</code> default to the value of the <code class="env">LANG</code>
environment variable.  If none of these variables are set, GCC
defaults to traditional C English behavior.
</p>
</dd>
<dt><a id="index-TMPDIR"></a><span><code class="env">TMPDIR</code><a class="copiable-link" href="#index-TMPDIR"> &para;</a></span></dt>
<dd><p>If <code class="env">TMPDIR</code> is set, it specifies the directory to use for temporary
files.  GCC uses temporary files to hold the output of one stage of
compilation which is to be used as input to the next stage: for example,
the output of the preprocessor, which is the input to the compiler
proper.
</p>
</dd>
<dt><a id="index-GCC_005fCOMPARE_005fDEBUG"></a><span><code class="env">GCC_COMPARE_DEBUG</code><a class="copiable-link" href="#index-GCC_005fCOMPARE_005fDEBUG"> &para;</a></span></dt>
<dd><p>Setting <code class="env">GCC_COMPARE_DEBUG</code> is nearly equivalent to passing
<samp class="option">-fcompare-debug</samp> to the compiler driver.  See the documentation
of this option for more details.
</p>
</dd>
<dt><a id="index-GCC_005fEXEC_005fPREFIX"></a><span><code class="env">GCC_EXEC_PREFIX</code><a class="copiable-link" href="#index-GCC_005fEXEC_005fPREFIX"> &para;</a></span></dt>
<dd><p>If <code class="env">GCC_EXEC_PREFIX</code> is set, it specifies a prefix to use in the
names of the subprograms executed by the compiler.  No slash is added
when this prefix is combined with the name of a subprogram, but you can
specify a prefix that ends with a slash if you wish.
</p>
<p>If <code class="env">GCC_EXEC_PREFIX</code> is not set, GCC attempts to figure out
an appropriate prefix to use based on the pathname it is invoked with.
</p>
<p>If GCC cannot find the subprogram using the specified prefix, it
tries looking in the usual places for the subprogram.
</p>
<p>The default value of <code class="env">GCC_EXEC_PREFIX</code> is
<samp class="file"><var class="var">prefix</var>/lib/gcc/</samp> where <var class="var">prefix</var> is the prefix to
the installed compiler. In many cases <var class="var">prefix</var> is the value
of <code class="code">prefix</code> when you ran the <samp class="file">configure</samp> script.
</p>
<p>Other prefixes specified with <samp class="option">-B</samp> take precedence over this prefix.
</p>
<p>This prefix is also used for finding files such as <samp class="file">crt0.o</samp> that are
used for linking.
</p>
<p>In addition, the prefix is used in an unusual way in finding the
directories to search for header files.  For each of the standard
directories whose name normally begins with &lsquo;<samp class="samp">/usr/local/lib/gcc</samp>&rsquo;
(more precisely, with the value of <code class="env">GCC_INCLUDE_DIR</code>), GCC tries
replacing that beginning with the specified prefix to produce an
alternate directory name.  Thus, with <samp class="option">-Bfoo/</samp>, GCC searches
<samp class="file">foo/bar</samp> just before it searches the standard directory 
<samp class="file">/usr/local/lib/bar</samp>.
If a standard directory begins with the configured
<var class="var">prefix</var> then the value of <var class="var">prefix</var> is replaced by
<code class="env">GCC_EXEC_PREFIX</code> when looking for header files.
</p>
</dd>
<dt><a id="index-COMPILER_005fPATH"></a><span><code class="env">COMPILER_PATH</code><a class="copiable-link" href="#index-COMPILER_005fPATH"> &para;</a></span></dt>
<dd><p>The value of <code class="env">COMPILER_PATH</code> is a colon-separated list of
directories, much like <code class="env">PATH</code>.  GCC tries the directories thus
specified when searching for subprograms, if it cannot find the
subprograms using <code class="env">GCC_EXEC_PREFIX</code>.
</p>
</dd>
<dt><a id="index-LIBRARY_005fPATH"></a><span><code class="env">LIBRARY_PATH</code><a class="copiable-link" href="#index-LIBRARY_005fPATH"> &para;</a></span></dt>
<dd><p>The value of <code class="env">LIBRARY_PATH</code> is a colon-separated list of
directories, much like <code class="env">PATH</code>.  When configured as a native compiler,
GCC tries the directories thus specified when searching for special
linker files, if it cannot find them using <code class="env">GCC_EXEC_PREFIX</code>.  Linking
using GCC also uses these directories when searching for ordinary
libraries for the <samp class="option">-l</samp> option (but directories specified with
<samp class="option">-L</samp> come first).
</p>
</dd>
<dt><a class="index-entry-id" id="index-locale-definition"></a>
<a id="index-LANG-1"></a><span><code class="env">LANG</code><a class="copiable-link" href="#index-LANG-1"> &para;</a></span></dt>
<dd><p>This variable is used to pass locale information to the compiler.  One way in
which this information is used is to determine the character set to be used
when character literals, string literals and comments are parsed in C and C++.
When the compiler is configured to allow multibyte characters,
the following values for <code class="env">LANG</code> are recognized:
</p>
<dl class="table">
<dt>&lsquo;<samp class="samp">C-JIS</samp>&rsquo;</dt>
<dd><p>Recognize JIS characters.
</p></dd>
<dt>&lsquo;<samp class="samp">C-SJIS</samp>&rsquo;</dt>
<dd><p>Recognize SJIS characters.
</p></dd>
<dt>&lsquo;<samp class="samp">C-EUCJP</samp>&rsquo;</dt>
<dd><p>Recognize EUCJP characters.
</p></dd>
</dl>

<p>If <code class="env">LANG</code> is not defined, or if it has some other value, then the
compiler uses <code class="code">mblen</code> and <code class="code">mbtowc</code> as defined by the default locale to
recognize and translate multibyte characters.
</p>
</dd>
<dt><a id="index-GCC_005fEXTRA_005fDIAGNOSTIC_005fOUTPUT"></a><span><code class="env">GCC_EXTRA_DIAGNOSTIC_OUTPUT</code><a class="copiable-link" href="#index-GCC_005fEXTRA_005fDIAGNOSTIC_005fOUTPUT"> &para;</a></span></dt>
<dd><p>If <code class="env">GCC_EXTRA_DIAGNOSTIC_OUTPUT</code> is set to one of the following values,
then additional text will be emitted to stderr when fix-it hints are
emitted.  <samp class="option">-fdiagnostics-parseable-fixits</samp> and
<samp class="option">-fno-diagnostics-parseable-fixits</samp> take precedence over this
environment variable.
</p>
<dl class="table">
<dt>&lsquo;<samp class="samp">fixits-v1</samp>&rsquo;</dt>
<dd><p>Emit parseable fix-it hints, equivalent to
<samp class="option">-fdiagnostics-parseable-fixits</samp>.  In particular, columns are
expressed as a count of bytes, starting at byte 1 for the initial column.
</p>
</dd>
<dt>&lsquo;<samp class="samp">fixits-v2</samp>&rsquo;</dt>
<dd><p>As <code class="code">fixits-v1</code>, but columns are expressed as display columns,
as per <samp class="option">-fdiagnostics-column-unit=display</samp>.
</p></dd>
</dl>

</dd>
</dl>

<p>Some additional environment variables affect the behavior of the
preprocessor.
</p>



<dl class="vtable">
<dt><a id="index-CPATH"></a><span><code class="env">CPATH</code><a class="copiable-link" href="#index-CPATH"> &para;</a></span></dt>
<dt><a id="index-C_005fINCLUDE_005fPATH"></a><span><code class="env">C_INCLUDE_PATH</code><a class="copiable-link" href="#index-C_005fINCLUDE_005fPATH"> &para;</a></span></dt>
<dt><a id="index-CPLUS_005fINCLUDE_005fPATH"></a><span><code class="env">CPLUS_INCLUDE_PATH</code><a class="copiable-link" href="#index-CPLUS_005fINCLUDE_005fPATH"> &para;</a></span></dt>
<dt><a id="index-OBJC_005fINCLUDE_005fPATH"></a><span><code class="env">OBJC_INCLUDE_PATH</code><a class="copiable-link" href="#index-OBJC_005fINCLUDE_005fPATH"> &para;</a></span></dt>
<dd><p>Each variable&rsquo;s value is a list of directories separated by a special
character, much like <code class="env">PATH</code>, in which to look for header files.
The special character, <code class="code">PATH_SEPARATOR</code>, is target-dependent and
determined at GCC build time.  For Microsoft Windows-based targets it is a
semicolon, and for almost all other targets it is a colon.
</p>
<p><code class="env">CPATH</code> specifies a list of directories to be searched as if
specified with <samp class="option">-I</samp>, but after any paths given with <samp class="option">-I</samp>
options on the command line.  This environment variable is used
regardless of which language is being preprocessed.
</p>
<p>The remaining environment variables apply only when preprocessing the
particular language indicated.  Each specifies a list of directories
to be searched as if specified with <samp class="option">-isystem</samp>, but after any
paths given with <samp class="option">-isystem</samp> options on the command line.
</p>
<p>In all these variables, an empty element instructs the compiler to
search its current working directory.  Empty elements can appear at the
beginning or end of a path.  For instance, if the value of
<code class="env">CPATH</code> is <code class="code">:/special/include</code>, that has the same
effect as &lsquo;<samp class="samp">-I.&nbsp;-I/special/include<!-- /@w --></samp>&rsquo;.
</p>

</dd>
<dt><a class="index-entry-id" id="index-dependencies-for-make-as-output"></a>
<a id="index-DEPENDENCIES_005fOUTPUT"></a><span><code class="env">DEPENDENCIES_OUTPUT</code><a class="copiable-link" href="#index-DEPENDENCIES_005fOUTPUT"> &para;</a></span></dt>
<dd><p>If this variable is set, its value specifies how to output
dependencies for Make based on the non-system header files processed
by the compiler.  System header files are ignored in the dependency
output.
</p>
<p>The value of <code class="env">DEPENDENCIES_OUTPUT</code> can be just a file name, in
which case the Make rules are written to that file, guessing the target
name from the source file name.  Or the value can have the form
&lsquo;<samp class="samp"><var class="var">file</var> <var class="var">target</var></samp>&rsquo;, in which case the rules are written to
file <var class="var">file</var> using <var class="var">target</var> as the target name.
</p>
<p>In other words, this environment variable is equivalent to combining
the options <samp class="option">-MM</samp> and <samp class="option">-MF</samp>
(see <a class="pxref" href="Preprocessor-Options.html">Options Controlling the Preprocessor</a>),
with an optional <samp class="option">-MT</samp> switch too.
</p>
</dd>
<dt><a class="index-entry-id" id="index-dependencies-for-make-as-output-1"></a>
<a id="index-SUNPRO_005fDEPENDENCIES"></a><span><code class="env">SUNPRO_DEPENDENCIES</code><a class="copiable-link" href="#index-SUNPRO_005fDEPENDENCIES"> &para;</a></span></dt>
<dd><p>This variable is the same as <code class="env">DEPENDENCIES_OUTPUT</code> (see above),
except that system header files are not ignored, so it implies
<samp class="option">-M</samp> rather than <samp class="option">-MM</samp>.  However, the dependence on the
main input file is omitted.
See <a class="xref" href="Preprocessor-Options.html">Options Controlling the Preprocessor</a>.
</p>
</dd>
<dt><a id="index-SOURCE_005fDATE_005fEPOCH"></a><span><code class="env">SOURCE_DATE_EPOCH</code><a class="copiable-link" href="#index-SOURCE_005fDATE_005fEPOCH"> &para;</a></span></dt>
<dd><p>If this variable is set, its value specifies a UNIX timestamp to be
used in replacement of the current date and time in the <code class="code">__DATE__</code>
and <code class="code">__TIME__</code> macros, so that the embedded timestamps become
reproducible.
</p>
<p>The value of <code class="env">SOURCE_DATE_EPOCH</code> must be a UNIX timestamp,
defined as the number of seconds (excluding leap seconds) since
01 Jan 1970 00:00:00 represented in ASCII; identical to the output of
<code class="code">date +%s</code> on GNU/Linux and other systems that support the
<code class="code">%s</code> extension in the <code class="code">date</code> command.
</p>
<p>The value should be a known timestamp such as the last modification
time of the source or package and it should be set by the build
process.
</p>
</dd>
</dl>


</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Precompiled-Headers.html">Using Precompiled Headers</a>, Previous: <a href="Spec-Files.html">Specifying Subprocesses and the Switches to Pass to Them</a>, Up: <a href="Invoking-GCC.html">GCC Command Options</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indices.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
